<%-- 
    Document   : PerformanceChart
    Created on : Nov 20, 2014, 3:33:17 PM
    Author     : user
--%>

<%@page import="newpackage.Chart"%>
<%@page import="org.jfree.chart.ChartUtilities"%>
<%@page import="java.util.ArrayList"%>
<%@page import="newpackage.ChartData"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="newpackage.ConnectionFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
    <%
   ArrayList<ChartData> chartData=new ArrayList<ChartData>();
  Connection con=ConnectionFactory.getConnection();
  Statement s=con.createStatement();
  String query="select * from file_performance";
  ResultSet rs=s.executeQuery(query);
  
  while(rs.next())
  {
  long time=Long.parseLong(rs.getString("execution_time"));
  ChartData cd=new ChartData();
  cd.setData(time);
  String name=rs.getString("file_name");
  cd.setRow_key(name.substring(name.lastIndexOf('/') + 1));
  cd.setColumn_key("execution_time");
  chartData.add(cd);
  }
  response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(response.getOutputStream(),Chart.createChart("File Generation Time","file_name","execution _time IN (ns)", chartData),700,350); 

    %>
    </body>
</html>
